package club.janna.jrpc.reference.demo.controller;

import club.janna.jrpc.annotation.JRPCReference;
import club.janna.jrpc.service.demo.domain.User;
import club.janna.jrpc.service.demo.result.SMSResult;
import club.janna.jrpc.service.demo.service.SMSService;
import club.janna.jrpc.service.demo.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Panbo.Guo
 */
@RestController
public class ReferenceController {

    @JRPCReference(loadBalancer = "round")
    private UserService userService;
    @JRPCReference(loadBalancer = "random")
    private SMSService smsService;

    @GetMapping("user")
    public User getUser(long id) {
        return userService.findById(id);
    }

    @GetMapping("msg")
    public SMSResult msg(String phone, String msg) {
        return smsService.sendMsg(phone, msg);
    }
}
